package scream.servlet;

import java.io.IOException;
import java.text.ParseException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import scream.excepcion.DAOExcepcion;
import scream.negocio.SeguridadNegocioCliente;
import scream.negocio.SeguridadNegocioUsuario;

/**
 * Servlet implementation class VerificaPoder
 */
@WebServlet("/VerificaPoder")
public class VerificaPoder extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public VerificaPoder() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		String a = request.getParameter("cbo1");
		String b = request.getParameter("cbo2");
		String c = request.getParameter("cbo3");
		double d = Double.parseDouble(request.getParameter("txtImporte"));
		
		//System.out.println(g);
		SeguridadNegocioCliente negocio = new SeguridadNegocioCliente();
		
		
		
		try {
			String resultado = negocio.ConsultarPoder(a, b, c, d);
			System.out.println("RESPUESTA ==> " + resultado+" <====");
			request.setAttribute("rest", resultado);
			
			
			RequestDispatcher rd = request.getRequestDispatcher("CargaVerificarPoder");
			rd.forward(request, response);
			
			//response.sendRedirect(request.getContextPath()
				//	+ "/UsuarioBuscarServlet");
		} catch (DAOExcepcion e1) {
			RequestDispatcher rd = request.getRequestDispatcher("errorVerifica.jsp");
			rd.forward(request, response);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
